package com.cloud.controller.admin;

import com.cloud.bean.user.User;
import com.cloud.common.BaseReturn;
import com.cloud.common.JwtUtils;
import com.cloud.controller.admin.from.UserFrom;
import com.cloud.service.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @Author liuyuan
 * @Date 2022/11/14 9:45 AM
 * @Version 1.0
 */
@RestController
@RequestMapping("admin")
public class AdminController {

    @Autowired
    UserService userService;

    @RequestMapping("login")
    public BaseReturn  login(@RequestBody UserFrom userFrom){
        if(userFrom.getUserName() == null){
            return BaseReturn.build("5000","账号不能为空");
        }
        if(userFrom.getPassword() == null){
            return BaseReturn.build("5000","密码不能为空");
        }
        BaseReturn baseReturn =  userService.login(userFrom);
        return baseReturn;

    }
}
